﻿<controls:ChildWindow x:Class="AppLab.Views.Login.PersonalSettings"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:local="clr-namespace:AppLab.Controls"
           xmlns:appLab="clr-namespace:AppLab"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           Width="270" Height="190" 
           Title="个人设置">
    
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <appLab:BooleanToVisibilityConverter x:Key="VisibleConverter"/>
        </Grid.Resources>
        <toolkit:BusyIndicator x:Name="busyIndicator" BusyContent="{Binding Path=ApplicationStrings.BusyIndicatorRegisteringUser, Source={StaticResource ResourceWrapper}}"
                             IsBusy="{Binding IsRegistering}">
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <RadioButton Name="ChangedPasswordRadio" Content="修改密码" GroupName="PersonalSettings" IsChecked="True" Margin="20,0,0,0"></RadioButton>
                    <RadioButton Name="ChangedEmailRadio" Content="更改邮箱" GroupName="PersonalSettings" Margin="50,0,0,0" Checked="ChangedEmail_Checked"></RadioButton>
                </StackPanel>

                <Grid Name="PasswordGrid" Visibility="{Binding ElementName=ChangedPasswordRadio,Path=IsChecked,Converter={StaticResource VisibleConverter}}">
                    <local:CustomDataForm x:Name="CustomDataForm" Margin="0,10,0,0"
                                  CurrentItem="{Binding}" AutoEdit="True" CommandButtonsVisibility="None" 
                                  AutoGeneratingField="CustomDataForm_AutoGeneratingField"
                                  Style="{StaticResource DataFormStyle}" />
                </Grid>

                <Grid Name="EmailGrid" Margin="20" Visibility="{Binding ElementName=ChangedEmailRadio,Path=IsChecked,Converter={StaticResource VisibleConverter}}">
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="显示名称："></TextBlock>
                            <TextBox Name="NewDisplayNameTextBox" Width="150" MaxLength="16"></TextBox>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                            <TextBlock Text="新邮箱："></TextBlock>
                            <TextBox Name="NewEamilTextBox" Width="150" Margin="13,0,0,0" MaxLength="32"></TextBox>
                        </StackPanel>
                        <TextBlock Name="TipForWorngEmail" Foreground="Red" Margin="63,5,0,0" FontSize="13"></TextBlock>
                    </StackPanel>
                </Grid>
            </StackPanel>
        </toolkit:BusyIndicator>
        <Button x:Name="CancelButton" Content="取消" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="确认" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
    </Grid>
</controls:ChildWindow>